home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
src
/
fig13_03.jar
/
Ch13
/
Fig13_03
/
fig13_03.cpp
Wrap
C/C++ Source or Header
|
1997-11-02
|
546b
|
36 lines
// Fig. 13.3: fig13_03.cpp
// Demonstrating stack unwinding.
#include <iostream>
#include <stdexcept>
using namespace std;
void function3() throw ( runtime_error )
{
throw runtime_error( "runtime_error in function3" );
}
void function2() throw ( runtime_error )
{
function3();
}
void function1() throw ( runtime_error )
{
function2();
}
int main()
{
try {
function1();
}
catch ( runtime_error e )
{
cout << "Exception occurred: " << e.what() << endl;
}
return 0;
}